--ffseat
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include('shared.lua')

local function HandleRollercoasterAnimation( vehicle, player )
	return player:SelectWeightedSequence( ACT_GMOD_SIT_ROLLERCOASTER ) 
end

function ENT:Initialize()
	self.ang = self.ang or Angle(0,0,0)
	self.rideid = nil
	self.Locked = false
	
	self.seat = ents.Create("prop_vehicle_prisoner_pod")
	self.seat.FakeParent = self
	self.seat:SetModel( "models/nova/airboat_seat.mdl" )
	self.seat:SetKeyValue("limitview", "0") 
	self.seat:SetKeyValue("vehiclescript", "scripts/vehicles/prisoner_pod.txt")
	
	self:SetNoDraw( true )
	
	self.seat:SetPos(self:GetPos()+Vector(0,0,0))
	self.seat.HandleAnimation = HandleRollercoasterAnimation
	
	--self.seat:SetParent(self:GetParent())
	
	self.seat:Spawn()
	self.seat:Activate()

	self.seat:SetAngles(self.ang)
	self.seat:SetCollisionGroup(COLLISION_GROUP_DEBRIS)
	self.seat:GetPhysicsObject():EnableGravity( false )
	self.seat:GetPhysicsObject():SetMass(1)
	constraint.Weld(  self.seat, self:GetParent(), 0,0, 0, true )
	--self.seat:SetParent(self)
end

function ENT:Lock()
	self.Locked = true
end
function ENT:Unlock()
	self.Locked = false
end

function ENT:KeyValue( key, value )
	if ( key == "ang" ) then
		local ang = string.Explode(" ",value)
		self.ang = Angle(ang[1],ang[2],ang[3])
	elseif ( key == "rideid" ) then
		self.rideid = value		
	end
	
end

function ENT:Think()
end

function ENT:Use(ply,caller)
	print(ply,caller,"Used")
end
